<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<html:html>
<head>
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/stkissue2.css" />
	
  	<script type='text/javascript' src='/ittl/dwr/interface/BCStkIssue2Service.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/engine.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/util.js'></script>
  	
<!--  ส่วนที่ 2 -->
<script language="JavaScript">
var	itemCode = "";
function getMaxDocNo(lineNumber, itemOffset) {

	var docDate = "<%=request.getParameter("docDate")%>";
	var myDocDate = new Date(docDate);
	var yearTh;
	if(myDocDate.getFullYear()<2500) {
		yearTh = myDocDate.getFullYear()+543-2500;		
	}else {
		yearTh = myDocDate.getFullYear()-2500;
	}
	var month = myDocDate.getMonth()+1;
	if(month<10) {
		month = "0"+month;
	}
	
	itemCode	= 	document.getElementById("itemCode"+itemOffset).innerHTML+"-";
	
	BCStkIssue2Service.getMaxDocNo(itemCode+yearTh+month, loadinfoDocNo);			  
}

//<!--  ส่วนที่ 3 -->
function loadinfoDocNo(maxDocNo){		
	
	//dwr.util.setValue("docNo", maxDocNo.docNo);	
	opener.document.getElementById("docNo").value = maxDocNo.docNo;	
	
	
	window.close(); 		
}
</script>
	
</head>

<body ><br />
	<center>

		<div>
		<table border="1">
			<tr>
				<td width="120">ชนิดเอกสาร</td>
				<td width="150">ชื่อ</td>				
			</tr>

			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,1)" >
						<label id="itemCode1" style="cursor:pointer">F1-CC</label>
					</a>
				</td>
				<td>แผนกต้นทุน</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,2)" >
						<label id="itemCode2" style="cursor:pointer">F1-DF</label>
					</a>
				</td>
				<td>ฝ่ายย้อม</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,3)" >
						<label id="itemCode3" style="cursor:pointer">F1-FW</label>
					</a>
				</td>
				<td>ฝ่ายทอ</td>
			</tr>	
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,4)" >
						<label id="itemCode4" style="cursor:pointer">F1-GA</label>
					</a>
				</td>
				<td>ฝ่ายธุรการ</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,5)" >
						<label id="itemCode5" style="cursor:pointer">F1-NP</label>
					</a>
				</td>
				<td>ฝ่ายผลิตภัณฑ์ใหม่</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,6)" >
						<label id="itemCode6" style="cursor:pointer">F1-PM</label>
					</a>
				</td>
				<td>ฝ่ายซ่อมกำลังบำรุงไฟฟ้า</td>
			</tr>			
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,7)" >
						<label id="itemCode7" style="cursor:pointer">F1-SP</label>
					</a>
				</td>
				<td></td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,8)" >
						<label id="itemCode8" style="cursor:pointer">F1-ST</label>
					</a>
				</td>
				<td>ฝ่ายคลังพัสดุและขนส่ง - 1</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,9)" >
						<label id="itemCode9" style="cursor:pointer">F1-SW</label>
					</a>
				</td>
				<td></td>
			</tr>			
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,10)" >
						<label id="itemCode10" style="cursor:pointer">F1-WM</label>
					</a>
				</td>
				<td>ฝ่ายซ่อมบำรุงเครื่องทอ</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,11)" >
						<label id="itemCode11" style="cursor:pointer">F1-YD</label>
					</a>
				</td>
				<td></td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,12)" >
						<label id="itemCode12" style="cursor:pointer">F2-GA</label>
					</a>
				</td>
				<td>ฝ่ายธุรการ โรงงานที่ 2</td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,13)" >
						<label id="itemCode13" style="cursor:pointer">F2-PM</label>
					</a>
				</td>
				<td></td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,14)" >
						<label id="itemCode14" style="cursor:pointer">F2-SP</label>
					</a>
				</td>
				<td></td>
			</tr>
			<tr>				
				<td><a href="#" onclick="getMaxDocNo(1,15)" >
						<label id="itemCode15" style="cursor:pointer">F2-ST</label>
					</a>
				</td>
				<td></td>
			</tr>								
		</table>
		
		</div>
		
		
	</center>
				
</body>

</html:html>